import {defineStore} from "pinia"
export const useProduct =defineStore('products',{
    state(){
        return{
            data:[]
        }

    },
    actions:{
        async fetch_data(){
            let res=await fetch('/api/data/index.json')
            .then(body=>body.json())
            console.log(res)
            this.data=res.data
        },

       
        delClick(nums){
            let target=this.data.find(item=>item.id==nums.id)
            if(target){
                target.inventory--
            }

        }

    }
})
